//
//  XxwsVC+UI.swift
//  Auscultation
//
//  Created by 来 on 2021/1/7.
//

import Foundation

extension XxwsVC {
    
    func initUI() {
        
        let top_view = UIImageView.init(image: #imageLiteral(resourceName: "beijing2@1.5x"))
        top_view.isUserInteractionEnabled = true
        view.addSubview(top_view)
        top_view.snp.makeConstraints { (make) in
            make.top.left.right.equalToSuperview()
            make.height.equalTo(UIDevice.lgf_NavBarH())
        }
        self.navTitle = type == 1 ? "完善信息" : "个人编辑"
        self.lgf_NavigationBar.lgf_Title?.textColor = UIColor.white
        
        scrollView = UIScrollView.lgf_Table("FFFFFF")
        if #available(iOS 11.0, *) {
            scrollView.contentInsetAdjustmentBehavior = .never
        } else {
            self.automaticallyAdjustsScrollViewInsets = false
        }
        view.addSubview(scrollView)
        scrollView.snp.makeConstraints { (make) in
            make.top.equalTo(top_view.snp.bottom)
            make.left.right.equalToSuperview()
            make.bottom.equalTo(0)
        }
        
        tx = LGFLoginImageTitleView.init(nil, #imageLiteral(resourceName: "icon_arrow"), left: 0, placeholder: "", text: "", true)
        tx.lgf_ViewName = "头像"
        tx.delegate = self
        scrollView.addSubview(tx)
        tx.snp.makeConstraints { (make) in
            make.width.equalToSuperview().offset(-30)
            make.centerX.equalToSuperview()
            make.top.equalToSuperview().offset(10)
            make.height.equalTo(44.lgf_H())
        }
        let tx_l = UILabel.init()
        tx_l.text = "头像"
        tx_l.textColor = UIColor.init(lgf_HexString: "222222")
        tx_l.font = UIFont.boldSystemFont(ofSize: 16)
        tx.addSubview(tx_l)
        tx_l.snp.makeConstraints { (make) in
            make.left.equalToSuperview()
            make.top.bottom.equalToSuperview()
        }
        tx_i = UIImageView.init(image: nil)
        tx_i.backgroundColor = UIColor.init(lgf_HexString: "F0F0F0")
        tx_i.layer.cornerRadius = 20
        tx_i.clipsToBounds = true
        tx_i.lgf_ViewName = ""
        tx.addSubview(tx_i)
        tx_i.snp.makeConstraints { (make) in
            make.centerY.equalToSuperview()
            make.right.equalToSuperview().offset(-30)
            make.width.height.equalTo(40)
        }
        
        xm = LGFLoginImageTitleView.init(nil, nil, left: 80, placeholder: "姓名", text: "", false)
        xm.delegate = self
        scrollView.addSubview(xm)
        xm.snp.makeConstraints { (make) in
            make.width.equalToSuperview().offset(-30)
            make.centerX.equalToSuperview()
            make.top.equalTo(tx.snp.bottom).offset(10)
            make.height.equalTo(44.lgf_H())
        }
        let xm_l = UILabel.init()
        xm_l.text = "姓名"
        xm_l.textColor = UIColor.init(lgf_HexString: "222222")
        xm_l.font = UIFont.boldSystemFont(ofSize: 16)
        xm.addSubview(xm_l)
        xm_l.snp.makeConstraints { (make) in
            make.left.equalToSuperview()
            make.top.bottom.equalToSuperview()
        }
        let xm_x = UILabel.init()
        xm_x.text = "*"
        xm_x.textColor = UIColor.init(lgf_HexString: "CE4C4C")
        xm_x.font = UIFont.boldSystemFont(ofSize: 16)
        xm.addSubview(xm_x)
        xm_x.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(-10)
            make.centerY.equalToSuperview().offset(2)
        }
        
        // 性别
        xb = LGFLoginImageTitleView.init(nil, #imageLiteral(resourceName: "icon_arrow"), left: 80, placeholder: "患者性别", text: "", true)
        xb.lgf_ViewName = "性别"
        xb.delegate = self
        scrollView.addSubview(xb)
        xb.snp.makeConstraints { (make) in
            make.width.equalToSuperview().offset(-30)
            make.centerX.equalToSuperview()
            make.top.equalTo(xm.snp.bottom).offset(10)
            make.height.equalTo(44.lgf_H())
        }
        let xb_l = UILabel.init()
        xb_l.text = "性别"
        xb_l.textColor = UIColor.init(lgf_HexString: "222222")
        xb_l.font = UIFont.boldSystemFont(ofSize: 16)
        xb.addSubview(xb_l)
        xb_l.snp.makeConstraints { (make) in
            make.left.equalToSuperview()
            make.top.bottom.equalToSuperview()
        }
        
        // 身份证
        sfz = LGFLoginImageTitleView.init(nil, nil, left: 80, placeholder: "18位身份证号", text: "", false)
        sfz.textField.delegate = self
        scrollView.addSubview(sfz)
        sfz.snp.makeConstraints { (make) in
            make.width.equalToSuperview().offset(-30)
            make.centerX.equalToSuperview()
            make.top.equalTo(xb.snp.bottom).offset(10)
            make.height.equalTo(44.lgf_H())
        }
        let sfz_l = UILabel.init()
        sfz_l.text = "身份证"
        sfz_l.textColor = UIColor.init(lgf_HexString: "222222")
        sfz_l.font = UIFont.boldSystemFont(ofSize: 16)
        sfz.addSubview(sfz_l)
        sfz_l.snp.makeConstraints { (make) in
            make.left.equalToSuperview()
            make.top.bottom.equalToSuperview()
        }
        let sfz_x = UILabel.init()
        sfz_x.text = "*"
        sfz_x.textColor = UIColor.init(lgf_HexString: "CE4C4C")
        sfz_x.font = UIFont.boldSystemFont(ofSize: 16)
        sfz.addSubview(sfz_x)
        sfz_x.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(-10)
            make.centerY.equalToSuperview().offset(2)
        }
        
        if type == 2 {
            sjh = LGFLoginImageTitleView.init(nil, nil, left: 80, placeholder: "手机号", text: "", false)
            scrollView.addSubview(sjh)
            sjh.snp.makeConstraints { (make) in
                make.width.equalToSuperview().offset(-30)
                make.centerX.equalToSuperview()
                make.top.equalTo(sfz.snp.bottom).offset(10)
                make.height.equalTo(44.lgf_H())
            }
            let sjh_l = UILabel.init()
            sjh_l.text = "手机号"
            sjh_l.textColor = UIColor.init(lgf_HexString: "222222")
            sjh_l.font = UIFont.boldSystemFont(ofSize: 16)
            sjh.addSubview(sjh_l)
            sjh_l.snp.makeConstraints { (make) in
                make.left.equalToSuperview()
                make.top.bottom.equalToSuperview()
            }
            let sjh_x = UILabel.init()
            sjh_x.text = "*"
            sjh_x.textColor = UIColor.init(lgf_HexString: "CE4C4C")
            sjh_x.font = UIFont.boldSystemFont(ofSize: 16)
            sjh.addSubview(sjh_x)
            sjh_x.snp.makeConstraints { (make) in
                make.left.equalToSuperview().offset(-10)
                make.centerY.equalToSuperview().offset(2)
            }
        }
        
        // 出生年月
        csrq = LGFLoginImageTitleView.init(nil, nil, left: 80, placeholder: "出生年月", text: "", true)
        csrq.lgf_ViewName = "出生年月"
        csrq.delegate = self
        csrq.isUserInteractionEnabled = false
        scrollView.addSubview(csrq)
        csrq.snp.makeConstraints { (make) in
            make.width.equalToSuperview().offset(-30)
            make.centerX.equalToSuperview()
            make.top.equalTo(type == 1 ? sfz.snp.bottom : sjh.snp.bottom).offset(10)
            make.height.equalTo(44.lgf_H())
        }
        let label3 = UILabel.init()
        label3.text = "出生年月"
        label3.textColor = UIColor.init(lgf_HexString: "222222")
        label3.font = UIFont.boldSystemFont(ofSize: 16)
        csrq.addSubview(label3)
        label3.snp.makeConstraints { (make) in
            make.left.equalToSuperview()
            make.top.bottom.equalToSuperview()
        }
        let csrq_v = UIView.init()
        csrq_v.backgroundColor = UIColor.white.withAlphaComponent(0.7)
        csrq.addSubview(csrq_v)
        csrq_v.snp.makeConstraints { (make) in
            make.edges.equalTo(UIEdgeInsets.init(top: 0, left: 0, bottom: 1, right: 0))
        }
        
        // 民族
        mz = LGFLoginImageTitleView.init(nil, #imageLiteral(resourceName: "icon_arrow"), left: 80, placeholder: "民族", text: "", true)
        mz.lgf_ViewName = "民族"
        mz.delegate = self
        scrollView.addSubview(mz)
        mz.snp.makeConstraints { (make) in
            make.width.equalToSuperview().offset(-30)
            make.centerX.equalToSuperview()
            make.top.equalTo(csrq.snp.bottom).offset(10)
            make.height.equalTo(44.lgf_H())
        }
        let mz_l = UILabel.init()
        mz_l.text = "民族"
        mz_l.textColor = UIColor.init(lgf_HexString: "222222")
        mz_l.font = UIFont.boldSystemFont(ofSize: 16)
        mz.addSubview(mz_l)
        mz_l.snp.makeConstraints { (make) in
            make.left.equalToSuperview()
            make.top.bottom.equalToSuperview()
        }
        
        // 专业
        zy = LGFLoginImageTitleView.init(nil, #imageLiteral(resourceName: "icon_arrow"), left: 80, placeholder: "专业", text: "", true)
        zy.lgf_ViewName = "专业"
        zy.delegate = self
        scrollView.addSubview(zy)
        zy.snp.makeConstraints { (make) in
            make.width.equalToSuperview().offset(-30)
            make.centerX.equalToSuperview()
            make.top.equalTo(mz.snp.bottom).offset(10)
            make.height.equalTo(44.lgf_H())
        }
        let zy_l = UILabel.init()
        zy_l.text = "专业"
        zy_l.textColor = UIColor.init(lgf_HexString: "222222")
        zy_l.font = UIFont.boldSystemFont(ofSize: 16)
        zy.addSubview(zy_l)
        zy_l.snp.makeConstraints { (make) in
            make.left.equalToSuperview()
            make.top.bottom.equalToSuperview()
        }
        let zy_x = UILabel.init()
        zy_x.text = "*"
        zy_x.textColor = UIColor.init(lgf_HexString: "CE4C4C")
        zy_x.font = UIFont.boldSystemFont(ofSize: 16)
        zy.addSubview(zy_x)
        zy_x.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(-10)
            make.centerY.equalToSuperview().offset(2)
        }
        
        if type == 2 {
            // 角色
            js = LGFLoginImageTitleView.init(nil, #imageLiteral(resourceName: "icon_arrow"), left: 80, placeholder: "角色", text: "", true)
            js.lgf_ViewName = "角色"
            js.delegate = self
            js.isUserInteractionEnabled = false
            scrollView.addSubview(js)
            js.snp.makeConstraints { (make) in
                make.width.equalToSuperview().offset(-30)
                make.centerX.equalToSuperview()
                make.top.equalTo(zy.snp.bottom).offset(10)
                make.height.equalTo(44.lgf_H())
            }
            let js_l = UILabel.init()
            js_l.text = "角色"
            js_l.textColor = UIColor.init(lgf_HexString: "222222")
            js_l.font = UIFont.boldSystemFont(ofSize: 16)
            js.addSubview(js_l)
            js_l.snp.makeConstraints { (make) in
                make.left.equalToSuperview()
                make.top.bottom.equalToSuperview()
            }
            let js_x = UILabel.init()
            js_x.text = "*"
            js_x.textColor = UIColor.init(lgf_HexString: "CE4C4C")
            js_x.font = UIFont.boldSystemFont(ofSize: 16)
            js.addSubview(js_x)
            js_x.snp.makeConstraints { (make) in
                make.left.equalToSuperview().offset(-10)
                make.centerY.equalToSuperview().offset(2)
            }
            let js_v = UIView.init()
            js_v.backgroundColor = UIColor.white.withAlphaComponent(0.7)
            js.addSubview(js_v)
            js_v.snp.makeConstraints { (make) in
                make.edges.equalTo(UIEdgeInsets.init(top: 0, left: 0, bottom: 1, right: 0))
            }
        }
        
        // 所属医院
        ssyy = LGFLoginImageTitleView.init(nil, #imageLiteral(resourceName: "icon_arrow"), left: 80, placeholder: "所属医院", text: "", true)
        ssyy.lgf_ViewName = "所属医院"
        ssyy.delegate = self
        ssyy.isUserInteractionEnabled = type == 1
        scrollView.addSubview(ssyy)
        ssyy.snp.makeConstraints { (make) in
            make.width.equalToSuperview().offset(-30)
            make.centerX.equalToSuperview()
            make.top.equalTo(type == 1 ? zy.snp.bottom : js.snp.bottom).offset(10)
            make.height.equalTo(44.lgf_H())
        }
        let ssyy_l = UILabel.init()
        ssyy_l.text = "所属医院"
        ssyy_l.textColor = UIColor.init(lgf_HexString: "222222")
        ssyy_l.font = UIFont.boldSystemFont(ofSize: 16)
        ssyy.addSubview(ssyy_l)
        ssyy_l.snp.makeConstraints { (make) in
            make.left.equalToSuperview()
            make.top.bottom.equalToSuperview()
        }
        let ssyy_x = UILabel.init()
        ssyy_x.text = "*"
        ssyy_x.textColor = UIColor.init(lgf_HexString: "CE4C4C")
        ssyy_x.font = UIFont.boldSystemFont(ofSize: 16)
        ssyy.addSubview(ssyy_x)
        ssyy_x.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(-10)
            make.centerY.equalToSuperview().offset(2)
        }
        if type != 1 {
            let ssyy_v = UIView.init()
            ssyy_v.backgroundColor = UIColor.white.withAlphaComponent(0.7)
            ssyy.addSubview(ssyy_v)
            ssyy_v.snp.makeConstraints { (make) in
                make.edges.equalTo(UIEdgeInsets.init(top: 0, left: 0, bottom: 1, right: 0))
            }
        }
        
        // 职称
        zc = LGFLoginImageTitleView.init(nil, #imageLiteral(resourceName: "icon_arrow"), left: 80, placeholder: "职称", text: "", true)
        zc.lgf_ViewName = "职称"
        zc.delegate = self
        scrollView.addSubview(zc)
        zc.snp.makeConstraints { (make) in
            make.width.equalToSuperview().offset(-30)
            make.centerX.equalToSuperview()
            make.top.equalTo(ssyy.snp.bottom).offset(10)
            make.height.equalTo(44.lgf_H())
        }
        let zc_l = UILabel.init()
        zc_l.text = "职称"
        zc_l.textColor = UIColor.init(lgf_HexString: "222222")
        zc_l.font = UIFont.boldSystemFont(ofSize: 16)
        zc.addSubview(zc_l)
        zc_l.snp.makeConstraints { (make) in
            make.left.equalToSuperview()
            make.top.bottom.equalToSuperview()
        }
        let zc_x = UILabel.init()
        zc_x.text = "*"
        zc_x.textColor = UIColor.init(lgf_HexString: "CE4C4C")
        zc_x.font = UIFont.boldSystemFont(ofSize: 16)
        zc.addSubview(zc_x)
        zc_x.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(-10)
            make.centerY.equalToSuperview().offset(2)
        }
        
        // 学历
        xl = LGFLoginImageTitleView.init(nil, #imageLiteral(resourceName: "icon_arrow"), left: 80, placeholder: "学历", text: "", true)
        xl.lgf_ViewName = "学历"
        xl.delegate = self
        scrollView.addSubview(xl)
        xl.snp.makeConstraints { (make) in
            make.width.equalToSuperview().offset(-30)
            make.centerX.equalToSuperview()
            make.top.equalTo(zc.snp.bottom).offset(10)
            make.height.equalTo(44.lgf_H())
        }
        let xl_l = UILabel.init()
        xl_l.text = "学历"
        xl_l.textColor = UIColor.init(lgf_HexString: "222222")
        xl_l.font = UIFont.boldSystemFont(ofSize: 16)
        xl.addSubview(xl_l)
        xl_l.snp.makeConstraints { (make) in
            make.left.equalToSuperview()
            make.top.bottom.equalToSuperview()
        }
        let xl_x = UILabel.init()
        xl_x.text = "*"
        xl_x.textColor = UIColor.init(lgf_HexString: "CE4C4C")
        xl_x.font = UIFont.boldSystemFont(ofSize: 16)
        xl.addSubview(xl_x)
        xl_x.snp.makeConstraints { (make) in
            make.left.equalToSuperview().offset(-10)
            make.centerY.equalToSuperview().offset(2)
        }
        
        // 学位
        xw = LGFLoginImageTitleView.init(nil, #imageLiteral(resourceName: "icon_arrow"), left: 80, placeholder: "学位", text: "", true)
        xw.lgf_ViewName = "学位"
        xw.delegate = self
        scrollView.addSubview(xw)
        xw.snp.makeConstraints { (make) in
            make.width.equalToSuperview().offset(-30)
            make.centerX.equalToSuperview()
            make.top.equalTo(xl.snp.bottom).offset(10)
            make.height.equalTo(44.lgf_H())
        }
        let xw_l = UILabel.init()
        xw_l.text = "学位"
        xw_l.textColor = UIColor.init(lgf_HexString: "222222")
        xw_l.font = UIFont.boldSystemFont(ofSize: 16)
        xw.addSubview(xw_l)
        xw_l.snp.makeConstraints { (make) in
            make.left.equalToSuperview()
            make.top.bottom.equalToSuperview()
        }
        
        if type == 1 {
            // 证书编号
            zsbh = LGFLoginImageTitleView.init(nil, nil, left: 80, placeholder: "证书编号", text: "", false)
            zsbh.delegate = self
            scrollView.addSubview(zsbh)
            zsbh.snp.makeConstraints { (make) in
                make.width.equalToSuperview().offset(-30)
                make.centerX.equalToSuperview()
                make.top.equalTo(xw.snp.bottom).offset(10)
                make.height.equalTo(44.lgf_H())
            }
            let zsbh_l = UILabel.init()
            zsbh_l.text = "证书编号"
            zsbh_l.textColor = UIColor.init(lgf_HexString: "222222")
            zsbh_l.font = UIFont.boldSystemFont(ofSize: 16)
            zsbh.addSubview(zsbh_l)
            zsbh_l.snp.makeConstraints { (make) in
                make.left.equalToSuperview()
                make.top.bottom.equalToSuperview()
            }
            let zsbh_x = UILabel.init()
            zsbh_x.text = "*"
            zsbh_x.textColor = UIColor.init(lgf_HexString: "CE4C4C")
            zsbh_x.font = UIFont.boldSystemFont(ofSize: 16)
            zsbh.addSubview(zsbh_x)
            zsbh_x.snp.makeConstraints { (make) in
                make.left.equalToSuperview().offset(-10)
                make.centerY.equalToSuperview().offset(2)
            }
        }
        
        // 电子邮箱
        dzyx = LGFLoginImageTitleView.init(nil, nil, left: 80, placeholder: "电子邮箱", text: "", false)
        dzyx.delegate = self
        scrollView.addSubview(dzyx)
        dzyx.snp.makeConstraints { (make) in
            make.width.equalToSuperview().offset(-30)
            make.centerX.equalToSuperview()
            make.top.equalTo(type == 1 ? zsbh.snp.bottom : xw.snp.bottom).offset(10)
            make.height.equalTo(44.lgf_H())
        }
        let dzyx_l = UILabel.init()
        dzyx_l.text = "电子邮箱"
        dzyx_l.textColor = UIColor.init(lgf_HexString: "222222")
        dzyx_l.font = UIFont.boldSystemFont(ofSize: 16)
        dzyx.addSubview(dzyx_l)
        dzyx_l.snp.makeConstraints { (make) in
            make.left.equalToSuperview()
            make.top.bottom.equalToSuperview()
        }
        
        // 地区
        dq = LGFLoginImageTitleView.init(nil, #imageLiteral(resourceName: "icon_arrow"), left: 80, placeholder: "地区信息", text: "", true)
        dq.lgf_ViewName = "地区"
        dq.delegate = self
        scrollView.addSubview(dq)
        dq.snp.makeConstraints { (make) in
            make.width.equalToSuperview().offset(-30)
            make.centerX.equalToSuperview()
            make.top.equalTo(dzyx.snp.bottom).offset(10)
            make.height.equalTo(44.lgf_H())
        }
        let label6 = UILabel.init()
        label6.text = "地区"
        label6.textColor = UIColor.init(lgf_HexString: "222222")
        label6.font = UIFont.boldSystemFont(ofSize: 16)
        dq.addSubview(label6)
        label6.snp.makeConstraints { (make) in
            make.left.equalToSuperview()
            make.top.bottom.equalToSuperview()
        }
        
        // 详细地址
        xxdz = LGFLoginImageTitleView.init(nil, nil, left: 80, placeholder: "街道信息", text: "", false)
        xxdz.delegate = self
        scrollView.addSubview(xxdz)
        xxdz.snp.makeConstraints { (make) in
            make.width.equalToSuperview().offset(-30)
            make.centerX.equalToSuperview()
            make.top.equalTo(dq.snp.bottom).offset(10)
            make.height.equalTo(44.lgf_H())
        }
        let label7 = UILabel.init()
        label7.text = "详细地址"
        label7.textColor = UIColor.init(lgf_HexString: "222222")
        label7.font = UIFont.boldSystemFont(ofSize: 16)
        xxdz.addSubview(label7)
        label7.snp.makeConstraints { (make) in
            make.left.equalToSuperview()
            make.top.bottom.equalToSuperview()
        }
        
        if type == 1 {
            sfzxxm = LGFLoginImageTitleView.init(nil, #imageLiteral(resourceName: "icon_arrow"), left: 0, placeholder: "", text: "", true)
            sfzxxm.lgf_ViewName = "身份证信息面"
            sfzxxm.delegate = self
            scrollView.addSubview(sfzxxm)
            sfzxxm.snp.makeConstraints { (make) in
                make.width.equalToSuperview().offset(-30)
                make.centerX.equalToSuperview()
                make.top.equalTo(xxdz.snp.bottom).offset(10)
                make.height.equalTo(44.lgf_H())
            }
            let sfzxxm_l = UILabel.init()
            sfzxxm_l.text = "身份证信息面"
            sfzxxm_l.textColor = UIColor.init(lgf_HexString: "222222")
            sfzxxm_l.font = UIFont.boldSystemFont(ofSize: 16)
            sfzxxm.addSubview(sfzxxm_l)
            sfzxxm_l.snp.makeConstraints { (make) in
                make.left.equalToSuperview()
                make.top.bottom.equalToSuperview()
            }
            sfzxxm_i = UIImageView.init(image: nil)
            sfzxxm_i.backgroundColor = UIColor.init(lgf_HexString: "F0F0F0")
            sfzxxm_i.layer.cornerRadius = 3
            sfzxxm_i.clipsToBounds = true
            sfzxxm_i.lgf_ViewName = ""
            sfzxxm.addSubview(sfzxxm_i)
            sfzxxm_i.snp.makeConstraints { (make) in
                make.centerY.equalToSuperview()
                make.right.equalToSuperview().offset(-30)
                make.height.equalTo(50)
                make.width.equalTo(80)
            }
            let sfzxxm_x = UILabel.init()
            sfzxxm_x.text = "*"
            sfzxxm_x.textColor = UIColor.init(lgf_HexString: "CE4C4C")
            sfzxxm_x.font = UIFont.boldSystemFont(ofSize: 16)
            sfzxxm.addSubview(sfzxxm_x)
            sfzxxm_x.snp.makeConstraints { (make) in
                make.left.equalToSuperview().offset(-10)
                make.centerY.equalToSuperview().offset(2)
            }
            
            sfzghm = LGFLoginImageTitleView.init(nil, #imageLiteral(resourceName: "icon_arrow"), left: 0, placeholder: "", text: "", true)
            sfzghm.lgf_ViewName = "身份证国徽面"
            sfzghm.delegate = self
            scrollView.addSubview(sfzghm)
            sfzghm.snp.makeConstraints { (make) in
                make.width.equalToSuperview().offset(-30)
                make.centerX.equalToSuperview()
                make.top.equalTo(sfzxxm.snp.bottom).offset(10)
                make.height.equalTo(44.lgf_H())
            }
            let sfzghm_l = UILabel.init()
            sfzghm_l.text = "身份证国徽面"
            sfzghm_l.textColor = UIColor.init(lgf_HexString: "222222")
            sfzghm_l.font = UIFont.boldSystemFont(ofSize: 16)
            sfzghm.addSubview(sfzghm_l)
            sfzghm_l.snp.makeConstraints { (make) in
                make.left.equalToSuperview()
                make.top.bottom.equalToSuperview()
            }
            sfzghm_i = UIImageView.init(image: nil)
            sfzghm_i.backgroundColor = UIColor.init(lgf_HexString: "F0F0F0")
            sfzghm_i.layer.cornerRadius = 3
            sfzghm_i.clipsToBounds = true
            sfzghm_i.lgf_ViewName = ""
            sfzghm.addSubview(sfzghm_i)
            sfzghm_i.snp.makeConstraints { (make) in
                make.centerY.equalToSuperview()
                make.right.equalToSuperview().offset(-30)
                make.height.equalTo(50)
                make.width.equalTo(80)
            }
            let sfzghm_x = UILabel.init()
            sfzghm_x.text = "*"
            sfzghm_x.textColor = UIColor.init(lgf_HexString: "CE4C4C")
            sfzghm_x.font = UIFont.boldSystemFont(ofSize: 16)
            sfzghm.addSubview(sfzghm_x)
            sfzghm_x.snp.makeConstraints { (make) in
                make.left.equalToSuperview().offset(-10)
                make.centerY.equalToSuperview().offset(2)
            }
            
            zgzs = LGFLoginImageTitleView.init(nil, #imageLiteral(resourceName: "icon_arrow"), left: 0, placeholder: "", text: "", true)
            zgzs.lgf_ViewName = "资格证书"
            zgzs.delegate = self
            scrollView.addSubview(zgzs)
            zgzs.snp.makeConstraints { (make) in
                make.width.equalToSuperview().offset(-30)
                make.centerX.equalToSuperview()
                make.top.equalTo(sfzghm.snp.bottom).offset(10)
                make.height.equalTo(44.lgf_H())
            }
            let zgzs_l = UILabel.init()
            zgzs_l.text = "资格证书"
            zgzs_l.textColor = UIColor.init(lgf_HexString: "222222")
            zgzs_l.font = UIFont.boldSystemFont(ofSize: 16)
            zgzs.addSubview(zgzs_l)
            zgzs_l.snp.makeConstraints { (make) in
                make.left.equalToSuperview()
                make.top.bottom.equalToSuperview()
            }
            zgzs_i = UIImageView.init(image: nil)
            zgzs_i.backgroundColor = UIColor.init(lgf_HexString: "F0F0F0")
            zgzs_i.layer.cornerRadius = 3
            zgzs_i.clipsToBounds = true
            zgzs_i.lgf_ViewName = ""
            zgzs.addSubview(zgzs_i)
            zgzs_i.snp.makeConstraints { (make) in
                make.centerY.equalToSuperview()
                make.right.equalToSuperview().offset(-30)
                make.height.equalTo(50)
                make.width.equalTo(80)
            }
            let zgzs_x = UILabel.init()
            zgzs_x.text = "*"
            zgzs_x.textColor = UIColor.init(lgf_HexString: "CE4C4C")
            zgzs_x.font = UIFont.boldSystemFont(ofSize: 16)
            zgzs.addSubview(zgzs_x)
            zgzs_x.snp.makeConstraints { (make) in
                make.left.equalToSuperview().offset(-10)
                make.centerY.equalToSuperview().offset(2)
            }
        }
        
        bc = UIButton.init(type: .custom)
        bc.backgroundColor = UIColor.init(lgf_HexString: EWEDarkMode.c_0F88F2)!
        bc.setTitle("保存", for: .normal)
        bc.layer.cornerRadius = 5
        bc.setTitleColor(EWEDarkMode.white(), for: .normal)
        bc.titleLabel?.font = UIFont.systemFont(ofSize: 15)
        bc.layer.masksToBounds = true
        bc.addTarget(self, action: #selector(XxwsVC.s_bc), for: .touchUpInside)
        scrollView.addSubview(bc)
        bc.snp.makeConstraints { (make) in
            make.top.equalTo(type == 1 ? zgzs.snp.bottom : xxdz.snp.bottom).offset(20)
            make.centerX.equalToSuperview()
            make.width.equalToSuperview().multipliedBy(0.5)
            make.height.equalTo(50)
        }
        
        scrollView.lgf_AutoContentSize(20)
    }
}

extension XxwsVC: UITextFieldDelegate {
    func textFieldDidEndEditing(_ textField: UITextField) {
        if textField == sfz.textField {
            csrq.textField.text = birthdayStrFromIdentityCard(numberStr: textField.text!)
        }
    }
}

extension XxwsVC {
    func birthdayStrFromIdentityCard(numberStr: String) -> (String) {
        var year:String = ""
        var month:String
        var day:String
        //截取前14位
//        let fontNumber = (numberStr as NSString).substringWithRange(NSMakeRange(0, 14))
        //判断是18位身份证还是15位身份证
        if (numberStr as NSString).length == 18 {
            year = (numberStr as NSString).substring(with: NSMakeRange(6, 4))
            month = (numberStr as NSString).substring(with: NSMakeRange(10, 2))
            day = (numberStr as NSString).substring(with: NSMakeRange(12, 2))
            let result = "\(year)-\(month)-\(day)"
            print(result)
            return result
        } else if (numberStr as NSString).length == 15 {
            year = (numberStr as NSString).substring(with: NSMakeRange(6, 2))
            month = (numberStr as NSString).substring(with: NSMakeRange(8, 2))
            day = (numberStr as NSString).substring(with: NSMakeRange(10, 2))
            let result = "19\(year)-\(month)-\(day)"
            print(result)
            return result
        } else {
            return "无法识别"
        }
    }
}

extension XxwsVC: LGFLoginImageTitleViewDelegate {
    func selectLGFLoginImageTitleView(_ view: LGFLoginImageTitleView) {
        self.view.endEditing(true)
        if view.lgf_ViewName == "性别" {
            let picker = LGFBottomPickerView()
            let data = ["男", "女"]
            let sindex = data.lgf_IndexOfObject(self.xb.textField.text ?? "男")
            picker.showIn(self.view, data, sindex) { [weak self] (view, name, index) in
                self?.xb.text = data[index]
                self?.xb.lgf_Name = (index + 1).description
            }
        } else if view.lgf_ViewName == "学历" {
            let picker = LGFBottomPickerView()
            let data = self.xlArr.map { (dict) -> String in
                return (dict["title"] as? String) ?? ""
            }
            let sindex = data.lgf_IndexOfObject(self.xl.textField.text ?? "")
            picker.showIn(self.view, data, sindex) { [weak self] (view, name, index) in
                self?.xl.text = data[index]
                self?.xl.lgf_Name = (self?.xlArr[index]["id"] as? String) ?? ""
            }
        } else if view.lgf_ViewName == "专业" {
            let picker = LGFBottomPickerView()
            let data = self.zyArr.map { (dict) -> String in
                return (dict["title"] as? String) ?? ""
            }
            let sindex = data.lgf_IndexOfObject(self.zy.textField.text ?? "")
            picker.showIn(self.view, data, sindex) { [weak self] (view, name, index) in
                self?.zy.text = data[index]
                self?.zy.lgf_Name = (self?.zyArr[index]["id"] as? String) ?? ""
            }
        } else if view.lgf_ViewName == "所属医院" {
            let picker = LGFBottomPickerView()
            let data = self.ssyyArr.map { (dict) -> String in
                return (dict["hospitalName"] as? String) ?? ""
            }
            let sindex = data.lgf_IndexOfObject(self.ssyy.textField.text ?? "")
            picker.showIn(self.view, data, sindex) { [weak self] (view, name, index) in
                self?.ssyy.text = data[index]
                self?.ssyy.lgf_Name = (self?.ssyyArr[index]["id"] as? String) ?? ""
            }
        } else if view.lgf_ViewName == "职称" {
            let picker = LGFBottomPickerView()
            let data = self.zcArr.map { (dict) -> String in
                return (dict["title"] as? String) ?? ""
            }
            let sindex = data.lgf_IndexOfObject(self.zc.textField.text ?? "")
            picker.showIn(self.view, data, sindex) { [weak self] (view, name, index) in
                self?.zc.text = data[index]
                self?.zc.lgf_Name = (self?.zcArr[index]["id"] as? String) ?? ""
            }
        } else if view.lgf_ViewName == "学位" {
            let picker = LGFBottomPickerView()
            let data = self.xwArr.map { (dict) -> String in
                return (dict["title"] as? String) ?? ""
            }
            let sindex = data.lgf_IndexOfObject(self.xw.textField.text ?? "")
            picker.showIn(self.view, data, sindex) { [weak self] (view, name, index) in
                self?.xw.text = data[index]
                self?.xw.lgf_Name = (self?.xwArr[index]["id"] as? String) ?? ""
            }
        } else if view.lgf_ViewName == "民族" {
            let picker = LGFBottomPickerView()
            let data = ["汉族", "蒙古族", "回族", "藏族", "维吾尔族", "苗族", "彝族", "壮族", "布依族", "朝鲜族", "满族", "侗族", "瑶族", "白族", "土家族", "哈尼族", "哈萨克族", "傣族", "黎族", "僳僳族", "佤族", "畲族", "高山族", "拉祜族", "水族", "东乡族", "纳西族", "景颇族", "柯尔克孜族", "土族", "达斡尔族", "仫佬族", "羌族", "布朗族", "撒拉族", "毛南族", "仡佬族", "锡伯族", "阿昌族", "普米族", "塔吉克族", "怒族", "乌孜别克族"]
            let sindex = data.lgf_IndexOfObject(self.mz.textField.text ?? "")
            picker.showIn(self.view, data, sindex) { [weak self] (view, name, index) in
                self?.mz.text = data[index]
            }
        } else if view.lgf_ViewName == "出生年月" {
            let picker = LGFBottomDatePickerView()
            picker.showIn(self.view, .date, "yyyy-MM-dd") { (view, date, timestamp) in
                self.csrq.text = timestamp.description.lgf_TimeStampToDate().lgf_TimeStr("yyyy-MM-dd")
                self.csrq.lgf_Name = timestamp.description
            }
        } else if view.lgf_ViewName == "地区" {
            LGFAddressPickerView().showIn(self.view) { [weak self] (view, name, adddress) in
                self?.dq.text = adddress
            }
        } else if view.lgf_ViewName == "头像" {
            let imagePickerController =  TZImagePickerController.init(maxImagesCount: 1, columnNumber: 1, delegate: self, pushPhotoPickerVc: true)
            imagePickerController?.lgf_Name = "头像"
            imagePickerController?.allowPickingVideo = false
            imagePickerController?.allowPickingGif = false
            UIApplication.shared.keyWindow?.rootViewController!.present(imagePickerController!, animated: true, completion: nil)
        } else if view.lgf_ViewName == "身份证信息面" {
            let imagePickerController =  TZImagePickerController.init(maxImagesCount: 1, columnNumber: 1, delegate: self, pushPhotoPickerVc: true)
            imagePickerController?.lgf_Name = "身份证信息面"
            imagePickerController?.allowPickingVideo = false
            imagePickerController?.allowPickingGif = false
            UIApplication.shared.keyWindow?.rootViewController!.present(imagePickerController!, animated: true, completion: nil)
        } else if view.lgf_ViewName == "身份证国徽面" {
            let imagePickerController =  TZImagePickerController.init(maxImagesCount: 1, columnNumber: 1, delegate: self, pushPhotoPickerVc: true)
            imagePickerController?.lgf_Name = "身份证国徽面"
            imagePickerController?.allowPickingVideo = false
            imagePickerController?.allowPickingGif = false
            UIApplication.shared.keyWindow?.rootViewController!.present(imagePickerController!, animated: true, completion: nil)
        } else if view.lgf_ViewName == "资格证书" {
            let imagePickerController =  TZImagePickerController.init(maxImagesCount: 1, columnNumber: 1, delegate: self, pushPhotoPickerVc: true)
            imagePickerController?.lgf_Name = "资格证书"
            imagePickerController?.allowPickingVideo = false
            imagePickerController?.allowPickingGif = false
            UIApplication.shared.keyWindow?.rootViewController!.present(imagePickerController!, animated: true, completion: nil)
        }
    }
}

extension XxwsVC: TZImagePickerControllerDelegate {
    func imagePickerController(_ picker: TZImagePickerController!, didFinishPickingPhotos photos: [UIImage]!, sourceAssets assets: [Any]!, isSelectOriginalPhoto: Bool, infos: [[AnyHashable : Any]]!) {
        EWERequest.uploadFile(photos, "0", "image") { [weak self] (url) in
            if picker.lgf_Name == "头像" {
                self?.tx_i.lgf_setImage(url)
                self?.tx.lgf_Name = url
            } else if picker.lgf_Name == "身份证信息面" {
                self?.sfzxxm_i.lgf_setImage(url)
                self?.sfzxxm.lgf_Name = url
            } else if picker.lgf_Name == "身份证国徽面" {
                self?.sfzghm_i.lgf_setImage(url)
                self?.sfzghm.lgf_Name = url
            } else if picker.lgf_Name == "资格证书" {
                self?.zgzs_i.lgf_setImage(url)
                self?.zgzs.lgf_Name = url
            }
        } _: { (error) in
            SVProgressHUD.showError(error)
        }
    }
}
